<%@page import="calendar.CalendarVo"%>
<%@page import="calendar.CalendarMyba"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.json.simple.JSONArray"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("utf-8"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		response.setContentType("text/plain; charset=utf-8");
		CalendarMyba sql = new CalendarMyba();
		Map<String, String> map = new HashMap<String, String>();
		
		map.put("find", "N");
		
		List<CalendarVo> lists = sql.list();
		
		JSONArray jsonArr = new JSONArray();
		
		if(lists.size() != 0){
			
			for(CalendarVo cv : lists){
				
				JSONObject jsonObj = new JSONObject();
				
				jsonObj.put("title", cv.getCal_title());
				jsonObj.put("start", cv.getCal_startdt());
				jsonObj.put("end", cv.getCal_enddt());
				
				if(!cv.getCal_back_color().trim().equalsIgnoreCase("basic")){
					jsonObj.put("backgroundColor", cv.getCal_back_color());
				}
				if(!cv.getCal_font_color().trim().equalsIgnoreCase("basic")){
					jsonObj.put("textColor", cv.getCal_font_color());
				}
				
				jsonArr.add(jsonObj);
				
			}//for
			
		}//if
		
		PrintWriter pw = response.getWriter();
		//System.out.println(jsonArr.toJSONString());
		pw.write(jsonArr.toJSONString());
		pw.flush();
		
		if(pw != null) pw.close();
	
	%>
</body>
</html>